package com.example.administrator.hellocomp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {



            if(intent.getAction().equals("wust.zz.mybroadcast")){
                Bundle bundle=intent.getExtras();
                String aa=bundle.getString("a");
                String bb=bundle.getString("b");
                String op=bundle.getString("op");
                double a=Double.parseDouble(aa);
                double b=Double.parseDouble(bb);
                double result=0;
                if(op.equals("+")) { result=a+b; }
                if(op.equals("-")) { result=a-b; }
                if(op.equals("*")) { result=a*b; }
                if(op.equals("/")) { result=a/b; }
                Toast.makeText(context,aa+op+bb+"="+result,Toast.LENGTH_SHORT).show();
            }



    }
}
